package com.xiaohudie.thread;

/**
 * @Author xiao hu die
 * @Date 2022/2/21 14:14
 * @Version 1.0
 */
public class Test11 {
 public static void main(String[] args) {
     Myclass myclass = new Myclass();
     Thread thread1 = new Thread(new Thread11(myclass));
     Thread thread2 = new Thread(new Thread11(myclass));
     thread1.setName("t1");
     thread2.setName("t2");
     thread1.start();
     try {
         Thread.sleep(1000);
     } catch (InterruptedException e) {
         e.printStackTrace();
     }
     thread2.start();
 }
static class Thread11 implements Runnable{
private Myclass myclass;
public Thread11(Myclass myclass){
    this.myclass =myclass;
}
    @Override
    public void run() {
if (Thread.currentThread().getName().equals("t1")){
    myclass.doSome();
}
if (Thread.currentThread().getName().equals("t2")){
    myclass.doOther();
}
    }
}
static class Myclass{
     public
     static void doSome(){
         System.out.println("doSome Begin");
         try {
             Thread.sleep(1000*10);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         System.out.println("doSome Over");
     }
     public  void doOther(){
         System.out.println("doOther Begin");
         System.out.println("doOther Over");

     }
 }
}
